package com.allwe.client.callBack;

import cn.hutool.core.util.ObjectUtil;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.RecordMetadata;

/**
 * 异步发送消息回调解析器
 */
public class CallBackImpl implements Callback {
    @Override
    public void onCompletion(RecordMetadata recordMetadata, Exception e) {
        if (ObjectUtil.isNull(e)) {
            // 解析回调元数据
            System.out.println("offset:" + recordMetadata.offset() + ",partition:" + recordMetadata.partition());
        } else {
            e.printStackTrace();
        }
    }
}
